using System;
using System.IO;
using Mercurial;

namespace CodeMinder.SCM.Hg
{
    public class HgSourceControlProvider
    {
        public void Poc()
        {
            string dest = Path.GetFullPath(@".\temp\");
            Console.WriteLine(dest);

            const string src = @"https://hg01.codeplex.com/codeminder";
            
            var cmd = new CloneCommand()
                .WithSource(src)
                .WithCompressedTransfer(true);

            cmd.Validate();

            
            Directory.CreateDirectory(dest);
            Client.Execute(dest, cmd);

            var repository = new Repository(dest);
            var changesets = repository.Log();
            
            foreach (var changeset in changesets)
            {
                Console.WriteLine(changeset.CommitMessage);
                Console.WriteLine(changeset.AuthorName);
                Console.WriteLine(changeset.RevisionNumber);
                
                foreach (var pathAction in changeset.PathActions)
                {
                    Console.WriteLine(pathAction.Action);
                    Console.WriteLine(pathAction.Path);
                    Console.WriteLine(pathAction.Source);
                }
            }

            Directory.Delete(dest, true);

        }
    }
}